<template>
  <div class="box">
    <div class="container">
      <el-input
        v-model="input1"
        class="w-50 m-2 ssInput"
        size="large"
        placeholder="输入订单号进行搜索"
        :prefix-icon="Search"
      />
      <div class="right">
        <el-icon @click="switchBtn">
          <SwitchButton />
        </el-icon>
        <el-avatar
          src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
        />
        <span>vivi</span>
      </div>
    </div>
    <el-dialog
      v-model="centerDialogVisible"
      title="退出系统"
      width="30%"
      align-center
    >
      <span>请确认是否退出系统</span>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="centerDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="layOut">退出</el-button>
          <!-- <el-button type="primary" @click="centerDialogVisible = false"
            >退出</el-button
          > -->
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { Search } from "@element-plus/icons-vue";
import { logout } from "../api/index";
import { toast } from "../tips/index";
import { useRouter } from "vue-router";
const router = useRouter();

const centerDialogVisible = ref(false);
const input1 = ref("");
function switchBtn() {
  centerDialogVisible.value = true;
}
function layOut() {
  logout().then((res) => {
    localStorage.removeItem("token");
    toast("您已退出登录");
    centerDialogVisible.value = false;
    router.push("/login");
  });
}
</script>

<style scoped>
.box {
  height: 100%;
  width: 100%;
  background: #5e72e4;
}
.ssInput {
  width: 20%;
}
.container {
  width: 95%;
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.right {
  height: 100%;
  display: flex;
  align-items: center;
  color: white;
  font-size: 20px;
}
.right > :nth-child(1) {
  margin-right: 30px;
}
.right > :nth-child(2) {
  margin-right: 20px;
}
</style>
